package com.gs.cd.service.resource.controller;


import com.gs.cd.api.ApiResult;
import com.gs.cd.model.resource.SysResourceGroup;
import com.gs.cd.model.resource.vo.SysResourceGroupCopyVo;
import com.gs.cd.service.resource.service.SysResourceGroupService;
import com.seven.mybatisx.controller.AbstractController;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * 资源组模块
 *
 * @author seven
 * @since 2020-12-22
 */
@RestController
@RequestMapping("/resource/sysResourceGroup")
public class SysResourceGroupController extends AbstractController<SysResourceGroup, SysResourceGroupService> {

    /**
     * 复制到其他销售单元
     *
     * @param sourceCode 源销售单元
     * @param targetCode 目标销售单元
     * @return
     */
    @PostMapping("copy")
    public ApiResult copy(@RequestParam String sourceCode, @RequestParam String targetCode) {
        // TODO: 2020/12/23 check saleCode的有效性
        boolean b = iService.copy(sourceCode, targetCode);
        return b ? ApiResult.success() : ApiResult.error();
    }

    /**
     * 拖拽排序
     *
     * @param ids 有序的id数组
     * @return
     */
    @PostMapping("/drag")
    public ApiResult drag(@RequestBody List<String> ids) {
        return iService.drag(ids) ? ApiResult.success() : ApiResult.error();
    }


}

